package com.example.tonjie.software_park_association;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

/**
 * 设置菜单
 * Created by TonJie on 2017/5/3.
 */

public class Setting extends Activity implements View.OnClickListener {

    private TextView New_message_to_remind;//新消息提醒
    private TextView Out_of_the_current_account;//退出当前账号
    private TextView personal_data;//个人信息
    private TextView feedback;//意见反馈
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setting);
        New_message_to_remind = (TextView) findViewById(R.id.New_message_to_remind);
        New_message_to_remind.setOnClickListener(this);
        Out_of_the_current_account = (TextView) findViewById(R.id.Out_of_the_current_account);
        Out_of_the_current_account.setOnClickListener(this);
        personal_data= (TextView) findViewById(R.id.The_personal_data);
        personal_data.setOnClickListener(this);
        feedback=(TextView)findViewById(R.id.feedback);
        feedback.setOnClickListener(this);


    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.Out_of_the_current_account:
                AlertDialog.Builder dialog=new AlertDialog.Builder(Setting.this);
                dialog.setTitle("您确定要退出当前账号?");
                dialog.setMessage("退出提醒");
                dialog.setCancelable(true);
                dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Toast.makeText(Setting.this, "您已经成功退出当前账号", Toast.LENGTH_SHORT).show();
                        Intent intent=new Intent(Setting.this,LoginActivity.class);
                        startActivity(intent);
                    }
                });
                dialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Toast.makeText(Setting.this, "成功取消", Toast.LENGTH_SHORT).show();
                    }
                });
                dialog.show();
                break;
            case R.id.New_message_to_remind:
                Intent intent=new Intent(Setting.this,New_Message_To_Remind.class);
                startActivity(intent);
                break;
            case R.id.The_personal_data:
                Intent intent1=new Intent(Setting.this,Personal_data.class);
                startActivity(intent1);
                break;
            case R.id.feedback:
                startActivity(new Intent(Setting.this,opinion.class));
                finish();
        }
    }
}
